<!-- eslint-disable vue/multi-word-component-names -->
<template>

    <div class="index-img">
        <img src="../assets/img/猴头.png" alt="Background">
    </div>
    <div class="nav">
        <Nav />
    </div>
    <div class="big-box">
        <div class="index-text">
            <div class="text-name">黑神话</div>
            <div class="text1">直面天命</div>
            <div class="text2">2024.8.20</div>
            <button class="buy-btn" @click="showOverlay">现在预购</button>
        </div>
        <div v-if="overlayVisible" class="overlay" @click.self="hideOverlay">
            <button class="close-btn" @click="hideOverlay">X</button>
            <div class="buy">
                <div class="buy-img">
                    <img v-if="selectedVersion === '数字标准版'" src="../assets/img/数字标准版.png" alt="数字标准版">
                    <img v-if="selectedVersion === '数字豪华版'" src="../assets/img/数字豪华版.png" alt="数字豪华版">
                </div>
                <div class="buy-choose">
                    <div class="platform-select">
                        <h1>选择平台</h1>
                        <button v-for="platform in platforms" :key="platform"
                            :class="{ active: selectedPlatform === platform }" @click="selectedPlatform = platform">
                            {{ platform }}
                        </button>
                    </div>
                    <div class="version-select">
                        <h1>选择版本</h1>
                        <button v-for="version in versions[selectedPlatform]" :key="version"
                            :class="{ active: selectedVersion === version }" @click="selectVersion(version)">
                            {{ version }}
                        </button>
                    </div>
                    <div class="buy-bottom">
                        <img src="../assets/img/预购后红葫芦.png" alt="预购">
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import Nav from './Nav.vue';

export default {
    components: {
        // eslint-disable-next-line vue/no-reserved-component-names
        Nav,
    },
    data() {
        return {
            overlayVisible: false,
            selectedPlatform: 'PC',
            selectedVersion: '数字标准版',
            platforms: ['PC', 'PS5'],
            versions: {
                PC: ['数字标准版', '数字豪华版'],
                PS5: ['数字标准版', '数字豪华版'],
            }
        };
    },
    methods: {
        showOverlay() {
            this.overlayVisible = true;
        },
        hideOverlay() {
            this.overlayVisible = false;
        },
        selectVersion(version) {
            this.selectedVersion = version;
        }
    }
};
</script>

<style scoped>
.big-box {
    width: 100%;
    height: 100vh;
    position: relative;
    display: flex;
    /* 添加 flex 布局 */
    flex-direction: column;
    /* 垂直排列 */
}

.index-nav {
    flex: 0 0 auto;
    /* 保持导航栏的大小不变 */
}


.index-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.index-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.index-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    letter-spacing: 1.5px;
    position: absolute;
    top: 50%;
    left: 500px;
    transform: translate(-50%, -50%);
    text-align: center;
}

.text-name,
.text1,
.text2 {
    font-family: '华文行楷', sans-serif;
    color: #d4c6b8;
    background-image: url('path/to/texture.jpg');
    background-attachment: fixed;
    background-repeat: repeat;
    background-size: contain;
    padding: 10px;
    display: inline-block;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.2), -1px -1px 0 rgba(0, 0, 0, 0.5);
    line-height: 1.5;
}

.text-name {
    font-size: 80px;
    transform: rotate(15deg);
}

.text1 {
    font-size: 80px;
    transform: rotate(-8deg);
}

.text2 {
    font-size: 120px;
    background: linear-gradient(45deg, rgba(255, 217, 0, 1) 0%, rgba(238, 162, 0, 1) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    transition: background-position 0.3s ease;
}

.buy-btn {
    font-family: '华文行楷', sans-serif;
    margin-top: 50px;
    width: 430px;
    height: 80px;
    background: linear-gradient(45deg, rgba(255, 217, 0, 1) 0%, rgba(238, 162, 0, 1) 100%), radial-gradient(circle at 50% 50%, rgba(255, 215, 0, 0.5), transparent 60%);
    background-size: 200% 200%;
    background-position: 50% 50%;
    border: none;
    font-size: 60px;
    color: #331a00;
    cursor: pointer;
    transition: background-position 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.buy-btn:hover {
    background-position: 100% 100%;
    transform: scale(1.05);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.buy {
    width: 90%;
    height: 88%;
    background-color: rgb(233, 233, 231);
    display: flex;
    flex-direction: row;
}

.buy-img {
    flex: 6;
    overflow: hidden;
}

.buy-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.buy-choose {
    flex: 4;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0;
}

.buy-choose button {
    background-color: #ffffff;
    padding: 10px 20px;
    margin: 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    width: 250px;
    height: 100px;
    box-sizing: border-box;
}

.buy-choose button.active {
    background-color: rgb(233, 169, 73);
    color: #eaeaea;
}

.buy-choose h1 {
    font-family: '楷体', 'STKaiti', '华文楷体', sans-serif;
}

.buy-bottom {
    margin-top: 70px;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

.buy-bottom img {
    width: 100%;
    height: auto;
    max-width: 100%;
    margin: 0 auto;
    display: block;
}

.version-select {
    margin-top: 20px;
}

.platform-select button,
.version-select button {
    padding: 10px 20px;
    margin: 5px;
    border: none;
    border-radius: 5px;
    background-color: rgba(234, 234, 232, 1);
    cursor: pointer;
    font-size: 36px;
    transition: background-color 0.3s;
}

.platform-select button.active,
.version-select button.active {
    background-color: rgb(233, 169, 73);
}

.close-btn {
    cursor: pointer;
}

/* Media Queries for Responsive Design */
@media (max-width: 1200px) {
    .text-name {
        font-size: 60px;
    }

    .text1 {
        font-size: 60px;
    }

    .text2 {
        font-size: 100px;
    }

    .buy-btn {
        width: 350px;
        height: 70px;
        font-size: 50px;
    }
}

@media (max-width: 768px) {
    .text-name {
        font-size: 50px;
    }

    .text1 {
        font-size: 50px;
    }

    .text2 {
        font-size: 80px;
    }

    .buy-btn {
        width: 300px;
        height: 60px;
        font-size: 40px;
    }

    .buy {
        flex-direction: column;
        height: 90%;
    }

    .buy-img {
        flex: none;
        height: 40%;
    }

    .buy-choose {
        flex: none;
        height: 60%;
    }

    .buy-choose button {
        width: 200px;
        height: 80px;
        font-size: 14px;
    }

    .platform-select button,
    .version-select button {
        padding: 8px 16px;
        font-size: 30px;
    }
}

@media (max-width: 480px) {
    .text-name {
        font-size: 40px;
    }

    .text1 {
        font-size: 40px;
    }

    .text2 {
        font-size: 60px;
    }

    .buy-btn {
        width: 250px;
        height: 50px;
        font-size: 30px;
    }

    .buy-choose button {
        width: 180px;
        height: 60px;
        font-size: 12px;
    }

    .platform-select button,
    .version-select button {
        padding: 6px 12px;
        font-size: 20px;
    }
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #eaeaea;
}
</style>
